<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
<#assign base=request.contextPath  />
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>登录</title>
    <link rel="stylesheet" href="${base}/frame/layui/css/layui.css">
    <link rel="stylesheet" href="${base}/frame/static/css/style.css">
    <link rel="icon" href="${base}/frame/static/image/code.png">

</head>
<body >
<script>
    //控制跳出ifream框架
    if (window != top)
        top.location.href = location.href;
</script>
<div class="login-main">
    <header class="layui-elip" style="text-shadow: 2px 0px 2px;"><img src="../frame/static/image/logo.png" style="border-radius:50% ;border-bottom: 15px solid #9AC748;" alt=""><span style="color: #9AC748;font-size: 39px;border-bottom: 5px solid;">企业</span>管理系统</header>
    <form class="layui-form layui-form-pane" method="get" action="">

        <div class="layui-form-item">
            <div class="layui-input-inline">
                <input style="border-color: #9ac748;" type="text" id="phone" name="account" class="layui-input" lay-verify="account" placeholder="用户名"  autocomplete="on" maxlength="20"/>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-inline">
                <input style="border-color: #9ac748;" type="password" id="password" name="password" class="layui-input" lay-verify="password" placeholder="密码"
                       maxlength="20"/>
            </div>
        </div>

        <div class="layui-form-item">
            <button type="button" class="layui-btn btn-submit layui-btn-primary"  lay-filter="sub" style="width: 350px;background-color: #9AC748;color:white;" id="login">立即登录</button>

        </div>
    <#--<p><a href="javascript:;" class="fr" style="color: #666666;">忘记密码？</a></p>-->
    </form>
</div>
<script src="${base}/js/jquery.min.js"></script>
<script type="text/javascript" src="${base}/frame/layui/layui.js"></script>
<script type="text/javascript">
    layui.use(['form', 'layer'], function () {

        // 操作对象
        var form = layui.form;
        var layer= layui.layer;
        var $= layui.jquery;

        // 验证
        form.verify({
            phone: function (value) {
                if (value == "") {
                    return "请输入手机号";
                }
            },
            password: function (value) {
                if (value == "") {
                    return "请输入密码";
                }
            },

        }),

        // 提交监听
        form.on('submit(sub)', function (data) {
            window.location.href='../main'
        });


    });
    //键盘事件
    $("body").bind("keydown",function(e){
        // 兼容FF和IE和Opera
        var theEvent = e || window.event;
        var code=theEvent.keyCode || theEvent.which || theEvent.charCode;
        if (code==13) {
            //回车执行查询
            $("#login").click();
        }
    });

    $('#login').on('click',function () {
        $.ajax({
            type: "POST",
            url: "${base}/comPtUser/login",
            data: {userName: $("#phone").val(), passWord: $("#password").val()},
            async:false,
            success: function (data) {
                if (data) {
                    window.location.href = "${base}/comPtUser/main";
                } else {
                    layer.alert("登录失败，审核未通过或密码错误")
                }

            }
        });
    })


</script>
</body>
</html>